/*
 * File:   Schwefel1_2.h
 * Author: jcrada
 *
 * Created on 26 May 2011, 1:01 PM
 */

#ifndef ECB_SCHWEFEL1_2_H
#define	ECB_SCHWEFEL1_2_H

#include "ecb/base/Problem.h"

namespace ecb {

    class Schwefel1_2 : public Problem {
    public:
        Schwefel1_2(const std::string& id = "Schwefel1_2", const std::string& name = "Schwefel1_2",
                int dimensions = 0, scalar minimum = -100, scalar maximum = 100,
                bool minimization = true) :
        Problem(id, name, dimensions, minimum, maximum, minimization) { }

        scalar f(const std::vector<scalar>& x) {
            scalar result = 0.0;
            for (size_t i = 0; i < x.size(); ++i) {
                scalar sum = 0.0;
                for (size_t j = 0; j <= i; ++j) {
                    sum += x[j];
                }
                result += sum * sum;
            }
            return result;
        }
    };
}


#endif	/* ECB_SCHWEFEL1_2_H */
